package com.jch.httpdemo;

import io.netty.channel.ChannelInitializer;
import io.netty.channel.socket.SocketChannel;
import io.netty.handler.codec.http.HttpRequestDecoder;
import io.netty.handler.codec.http.HttpResponseEncoder;


public class HttpChannelInitializer extends ChannelInitializer<SocketChannel> {

    @Override
    protected void initChannel(SocketChannel ch) throws Exception {
        // 数据解码操作
        ch.pipeline().addLast(new HttpResponseEncoder());
        // 数据编码操作
        ch.pipeline().addLast(new HttpRequestDecoder());
        // 自定义数据处理器
        ch.pipeline().addLast(new HttpServerHandler());
    }
}
